package edu.sctu.zhoumengxue.day201506.day20150626.practicePost;

import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by user12 on 2015/6/26.
 */
public class postWeb {

    public int count = 0;
    public String string = "";
    public byte[] bytes = new byte[1024];

    public String getPost(String path){
        try {
            URL url  = new URL(path);
            try {
                URLConnection connection = url.openConnection();
                connection.connect();

                InputStream in = connection.getInputStream();
                while ((count = in.read(bytes))!=-1){
                    string = string + new String(bytes,0,count);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        return string;
    }
}
